package com.noahplat.user.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;


/**
 * 作者：李景星
 * 描述：用户实体类
 * 时间：2020-10-31
 */
@Data
@Table(name = "tb_user")
public class User {
    @Id
    @KeySql(useGeneratedKeys = true)
    private Long id;    //主键ID

    @NotEmpty
    private Long acctid;    //主键账套

    @NotNull(message = "参数不能为null")
    @Length(max = 32, message = "长度不能超过32位")
    private String username;    //账号

    @NotNull(message = "参数不能为null")
    @Length(max = 64, message = "长度不能超过64位")
    private String password;    //密码

    @NotNull(message = "参数不能为null")
    @Length(max = 32, message = "长度不能超过32位")
    private String name;    //用户名

    @NotNull(message = "参数不能为null")
    @Length(min = 11, max = 11, message = "长度不能超过11位")
    private String phone;   //手机号

    @NotNull(message = "参数不能为null")
    @Email
    @Length(max = 32, message = "长度不能超过32位")
    private String email;   //邮箱

    @NotEmpty(message = "参数不能为空")
    private Character del = 'N';  //是否删除 Y-已经删除；N-未删除

    @NotNull(message = "参数不能为null")
    @Column(name = "user_type")
    private String userType; //登录方式： 0-PC,1-APP，2-app&pc

    @NotEmpty(message = "登录账号属性不能为空")
    @Column(name = "user_pro")
    private String userPro; //登录账号属性，标识当前账号是否为企业管理账号，0为企业管理账号 1为个人账号

    @NotEmpty(message = "系统标识不能为空")
    private Long stid; //系统标识

    @Column(name = "created_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    private Long pid;  //关联persionId

    //新增 头像id 2021-03-13
    private String avatar;

    @Transient
    List<Role> list;
    @Transient
    private Long[] newrid;  //新角色
    @Transient
    private Long[] oldrid;

    @Transient
    private Long rid;    //管理员角色

    @Transient
    private String sysname;    //系统名称

    @Transient
    private String accountname;   //账套名称

}
